﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace XGameFrame.Graphic
{
    /// <summary>
    /// To animate creeps
    /// </summary>
    public class AnimatedCreepSprite : AnimatedSpriteBase
    {
        #region Fields Region
        #endregion

        #region Property Region
        #endregion

        #region Constructor
        /// <summary>
        /// Constructor for a new AnimatedCreepSprite with Animation
        /// </summary>
        /// <param name="pTexture">The Graphic to draw</param>
        /// <param name="pRows">The number of rows</param>
        /// <param name="pColumns">The number of columns</param>
        /// <param name="pBounds">The rectangle around the graphic</param>
        public AnimatedCreepSprite(Texture2D pTexture, int pRows, int pColumns, Vector2 pPosition)
            : base(pTexture, pRows, pColumns, pPosition)
        {
            SourceRectangle = new Rectangle(
            (int)FrameSize.X * CurrentCulumn,
            (int)FrameSize.Y * CurrentRow,
            (int)FrameSize.X,
            (int)FrameSize.Y);

            DestRectangle = new Rectangle((int)Position.X,
                (int)Position.Y,
                (int)FrameSize.X,
                (int)FrameSize.Y);

        }

        #endregion

        #region Abstract Method Region
        /// <summary>
        /// Do Logic for AnimatedSprites
        /// </summary>
        public override void Update(GameTime pGameTime)
        {
            
            Bounds = new Rectangle((int)Position.X,
            (int)Position.Y,
            (int)FrameSize.X,
            (int)FrameSize.Y);
            SourceRectangle = new Rectangle(
            (int)FrameSize.X * CurrentCulumn,
            (int)FrameSize.Y * CurrentRow,
            (int)FrameSize.X,
            (int)FrameSize.Y);

            DestRectangle = new Rectangle((int)Position.X,
                (int)Position.Y,
                (int)FrameSize.X,
                (int)FrameSize.Y);
            base.Update(pGameTime);
        }

        /// <summary>
        /// Do drawings for AnimatedSprites
        /// </summary>
        /// <param name="pSpriteBatch">The SpriteBatch from Xna Framework</param>
        public override void Draw(SpriteBatch pSpriteBatch)
        {
            pSpriteBatch.Draw(Texture,Position,SourceRectangle, Color.White,Rotation,Origin,Scale,SpriteEffect,LayerDepth);
        }
        /// <summary>
        /// Do Logic if Control is Hovered
        /// </summary>
        /// <param name="pPlayerIndex">The Input from PlayerIndex</param>
        public override void OnHover(PlayerIndex pPlayerIndex)
        {
        }
        /// <summary>
        /// Do Logic if it is Enabled
        /// </summary>
        /// <param name="pPlayerIndex">The Input from PlayerIndex</param>
        public override void HandleInput(PlayerIndex pPlayerIndex)
        {
            
        }

        #endregion
    }
}
